package com.fms.result;

import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;

@Data
@Accessors(chain = true)
//封装返回值
public class ResultData implements Serializable {
    public static final Integer OK = 200;
    private Integer code = OK;
    private String message;
    private Object data;

    private ResultData (){}

    public static ResultData success(){
        return new ResultData().setMessage("success");
    }

    public static ResultData success(String message){
        return new ResultData().setMessage(message);
    }

    public static ResultData success(Object data){
        return new ResultData().setData(data).setMessage("success");
    }

    public static ResultData success(String message, Object data){
        return new ResultData().setMessage(message).setData(data);
    }

    public static ResultData error(){
        return new ResultData().setMessage("error").setCode(3800);
    }

    public static ResultData error(String message){
        return new ResultData().setMessage(message).setCode(3800);
    }
}
